#include "socket.h"
#include <stdlib.h>
#include <glib-object.h>

typedef struct _SocketSocket {
  GObject parent_instance;

  gchar *class;

  gint64 id;
  gint64 parentID;
  gint64 timeout;
  gint64 interval;

  gint fd;
  gint port;
  gint type;
  gint deferredExecution;

  gint baud;
  gint dataBit;
  gint stopBit;
  gint parity;

  gint status;
  gint enable;
  gint update;
  gint mutex;

  gpointer buffer;
  gint bufferSize;
  gint nread;
  gint nwrote;

  gchar *ip;
  gchar *user;
  gchar *pwd;
  gchar *clientID;

  gchar *describe;
  gchar *name;
  gchar *nameAlias;

  gfloat x;
  gfloat y;
  gfloat z;

  gpointer funcSend, channel, conn, funcPrefixSend;
  gpointer data, addr, socket, clientAddress;
  gpointer son, parent, next, private;

} SocketSocket;
enum {
  PROP_0,
  PROP_CLASS,
  PROP_ID, PROP_PARENT_ID, PROP_TIMEOUT, PROP_INTERVAL,
  PROP_FD, PROP_PORT, PROP_TYPE, PROP_DEFERRED_EXECUTION,
  PROP_BAUD, PROP_DATA_BIT, PROP_STOP_BIT, PROP_PARITY,
  PROP_STATUS, PROP_ENABLE, PROP_UPDATE, PROP_MUTEX, 
  PROP_BUFFER, PROP_BUFFER_SIZE, PROP_NREAD, PROP_NWROTE,
  PROP_IP, PROP_USER, PROP_PWD, PROP_CLIENT_ID,
  PROP_DESCRIBE, PROP_NAME, PROP_NAME_ALIAS,
  PROP_X, PROP_Y, PROP_Z,
  PROP_FUNC_SEND, PROP_CHANNEL, PROP_CONN, PROP_FUNC_PREFIX_SEND,
  PROP_DATA, PROP_ADDR, PROP_SOCKET, PROP_CLIENT_ADDRESS,
  PROP_SON, PROP_PARENT, PROP_NEXT, PROP_PRIVATE,
  N_PROPERTIES };

static GParamSpec *properties[N_PROPERTIES] = { NULL, };

G_DEFINE_TYPE(SocketSocket, socket_socket, G_TYPE_OBJECT)
//int64
static void
socket_socket_set_id(SocketSocket *obj,
                     gint64    value)
{
  if (obj->id != value)
    {
      obj->id = value;

      g_assert(properties[PROP_ID] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_ID]);
    }
}
static void
socket_socket_set_parentID(SocketSocket *obj,
                     gint64    value)
{
  if (obj->parentID != value)
    {
      obj->parentID = value;

      g_assert(properties[PROP_PARENT_ID] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_PARENT_ID]);
    }
}
static void
socket_socket_set_timeout(SocketSocket *obj,
                     gint64    value)
{
  if (obj->timeout != value)
    {
      obj->timeout = value;

      g_assert(properties[PROP_TIMEOUT] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_TIMEOUT]);
    }
}
static void
socket_socket_set_interval(SocketSocket *obj,
                     gint64    value)
{
  if (obj->interval != value)
    {
      obj->interval = value;

      g_assert(properties[PROP_INTERVAL] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_INTERVAL]);
    }
}
//int
static void socket_socket_set_type(SocketSocket *obj, gint value)
{
  if (obj->type != value)
    {
      obj->type = value;

      g_assert(properties[PROP_TYPE] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_TYPE]);
    }
}
static void socket_socket_set_deferredExecution(SocketSocket *obj, gint value)
{
  if (obj->deferredExecution != value)
    {
      obj->deferredExecution = value;

      g_assert(properties[PROP_DEFERRED_EXECUTION] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj),
          properties[PROP_DEFERRED_EXECUTION]);
    }
}

static void
socket_socket_set_baud(SocketSocket *obj,
                     gint        value)
{
  if (obj->baud != value)
    {
      obj->baud = value;

      g_assert(properties[PROP_BAUD] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_BAUD]);
    }
}
static void
socket_socket_set_dataBit(SocketSocket *obj,
                     gint        value)
{
  if (obj->dataBit != value)
    {
      obj->dataBit = value;

      g_assert(properties[PROP_DATA_BIT] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_DATA_BIT]);
    }
}
static void
socket_socket_set_stopBit(SocketSocket *obj,
                     gint        value)
{
  if (obj->stopBit != value)
    {
      obj->stopBit = value;

      g_assert(properties[PROP_STOP_BIT] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_STOP_BIT]);
    }
}
static void
socket_socket_set_parity(SocketSocket *obj,
                     gint        value)
{
  if (obj->parity != value)
    {
      obj->parity = value;

      g_assert(properties[PROP_PARITY] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_PARITY]);
    }
}
static void socket_socket_set_status(SocketSocket *obj, gint    status)
{
  if (obj->status != status)
    {
      obj->status = status;

      g_assert(properties[PROP_STATUS] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_STATUS]);
    }
}
static void socket_socket_set_enable(SocketSocket *obj, gint   value)
{
  if (obj->enable != value)
    {
      obj->enable = value;
      g_assert(properties[PROP_ENABLE] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_ENABLE]);
    }
}
static void socket_socket_set_mutex(SocketSocket *obj, gint    value)
{
  if (obj->mutex != value)
    {
      obj->mutex = value;
      g_assert(properties[PROP_MUTEX] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_MUTEX]);
    }
}
static void socket_socket_set_update(SocketSocket *obj, gint    value)
{
  if (obj->update != value)
    {
      obj->update = value;

      g_assert(properties[PROP_UPDATE] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_UPDATE]);
    }
}
//char
static void
socket_socket_set_ip(SocketSocket  *obj,
                     const gchar *ip)
{
  if (g_strcmp0(obj->ip, ip) != 0)
    {
      g_free(obj->ip);
      obj->ip = g_strdup(ip);

      g_assert(properties[PROP_IP] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_IP]);
    }
}
static void
socket_socket_set_user(SocketSocket  *obj,
                      const gchar *user)
{
  if (g_strcmp0(obj->user, user) != 0)
    {
      g_free(obj->user);
      obj->user = g_strdup(user);

      g_assert(properties[PROP_USER] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_USER]);
    }
}
static void
socket_socket_set_pwd(SocketSocket  *obj,
                      const gchar *pwd)
{
  if (g_strcmp0(obj->pwd, pwd) != 0)
    {
      g_free(obj->pwd);
      obj->pwd = g_strdup(pwd);

      g_assert(properties[PROP_PWD] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_PWD]);
    }
}
static void
socket_socket_set_clientID(SocketSocket  *obj,
                      const gchar *value)
{
  if (g_strcmp0(obj->clientID, value) != 0)
    {
      g_free(obj->clientID);
      obj->clientID = g_strdup(value);

      g_assert(properties[PROP_CLIENT_ID] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_CLIENT_ID]);
    }
}
static void
socket_socket_set_describe(SocketSocket  *obj,
                      const gchar *value)
{
  if (g_strcmp0(obj->describe, value) != 0)
    {
      g_free(obj->describe);
      obj->describe = g_strdup(value);

      g_assert(properties[PROP_DESCRIBE] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_DESCRIBE]);
    }
}
static void socket_socket_set_class(SocketSocket *obj, const gchar *value)
{
  if (g_strcmp0(obj->class, value) != 0)
    {
      g_free(obj->class);
      obj->class = g_strdup(value);

      g_assert(properties[PROP_CLASS] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_CLASS]);
    }
}
static void
socket_socket_set_name(SocketSocket  *obj,
                      const gchar *value)
{
  if (g_strcmp0(obj->name, value) != 0)
    {
      g_free(obj->name);
      obj->name = g_strdup(value);

      g_assert(properties[PROP_NAME] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_NAME]);
    }
}
static void
socket_socket_set_nameAlias(SocketSocket  *obj,
                      const gchar *value)
{
  if (g_strcmp0(obj->nameAlias, value) != 0)
    {
      g_free(obj->nameAlias);
      obj->nameAlias = g_strdup(value);

      g_assert(properties[PROP_NAME_ALIAS] != NULL);
      g_object_notify_by_pspec(G_OBJECT(obj), properties[PROP_NAME_ALIAS]);
    }
}
//object
static void
socket_socket_set_next(SocketSocket  *obj,
                      gpointer next)
{
    obj->next = next;
}
//float
static void socket_socket_set_x(SocketSocket  *obj, gfloat value)
{
    obj->x = value;
}
static void socket_socket_set_y(SocketSocket  *obj, gfloat value)
{
    obj->y = value;
}
static void socket_socket_set_z(SocketSocket  *obj, gfloat value)
{
    obj->z = value;
}
//void 
static void
socket_socket_set_son(SocketSocket  *obj,
                      gpointer son)
{
    obj->son = son;
}
static void
socket_socket_set_parent(SocketSocket  *obj,
                      gpointer value)
{
    obj->parent = value;
}
static void
socket_socket_set_private(SocketSocket  *obj,
                      gpointer value)
{
    obj->private = value;
}

static void
socket_socket_finalize(GObject *gobject)
{
  SocketSocket *self = (SocketSocket *) gobject;

  if (self->next)
    g_object_unref(self->next);
  if (self->son)
    g_object_unref(self->son);

  if (self->buffer)
    g_free(self->buffer);
  if (self->ip)
    g_free(self->ip);
  if (self->user)
    g_free(self->user);
  if (self->pwd)
    g_free(self->pwd);
  if (self->clientID)
    g_free(self->clientID);

  if (self->describe)
    g_free(self->describe);
  if (self->name)
    g_free(self->name);
  if (self->nameAlias)
    g_free(self->nameAlias);
  if (self->class)
    g_free(self->class);

  g_object_notify(gobject, "port");
  g_object_notify_by_pspec(gobject, properties[PROP_STATUS]);

  G_OBJECT_CLASS(socket_socket_parent_class)->finalize(gobject);
}

static void
socket_socket_set_property(GObject *gobject,
                          guint prop_id,
                          const GValue *value,
                          GParamSpec *pspec)
{
  SocketSocket *tobj = (SocketSocket *) gobject;

  g_assert_cmpint(prop_id, !=, 0);
  g_assert_cmpint(prop_id, !=, N_PROPERTIES);
  g_assert(pspec == properties[prop_id]);

  switch (prop_id)
    {
    case PROP_ID:
      socket_socket_set_id(tobj, g_value_get_int64(value));
      break;
    case PROP_PARENT_ID:
      socket_socket_set_parentID(tobj, g_value_get_int64(value));
      break;
    case PROP_TIMEOUT:
      socket_socket_set_timeout(tobj, g_value_get_int64(value));
      break;
    case PROP_INTERVAL:
      socket_socket_set_interval(tobj, g_value_get_int64(value));
      break;

    case PROP_STATUS:
      socket_socket_set_status(tobj, g_value_get_int(value));
      break;
    case PROP_ENABLE:
      socket_socket_set_enable(tobj, g_value_get_int(value));
      break;
    case PROP_UPDATE:
      socket_socket_set_update(tobj, g_value_get_int(value));
      break;
    case PROP_MUTEX:
      socket_socket_set_mutex(tobj, g_value_get_int(value));
      break;

    case PROP_FD:
      tobj->fd = g_value_get_int(value);
      break;
    case PROP_PORT:
      tobj->port = g_value_get_int(value);
      break;
    case PROP_TYPE:
      socket_socket_set_type(tobj, g_value_get_int(value));
      break;
    case PROP_DEFERRED_EXECUTION:
      socket_socket_set_deferredExecution(tobj, g_value_get_int(value));
      break;

    case PROP_BAUD:
      socket_socket_set_baud(tobj, g_value_get_int(value));
      break;
    case PROP_DATA_BIT:
      socket_socket_set_dataBit(tobj, g_value_get_int(value));
      break;
    case PROP_STOP_BIT:
      socket_socket_set_stopBit(tobj, g_value_get_int(value));
      break;
    case PROP_PARITY:
      socket_socket_set_parity(tobj, g_value_get_int(value));
      break;

    case PROP_BUFFER_SIZE:
      tobj->bufferSize = g_value_get_int(value);
      break;
    case PROP_NREAD:
      tobj->nread = g_value_get_int(value);
      break;
    case PROP_NWROTE:
      tobj->nwrote = g_value_get_int(value);
      break;

    case PROP_IP:
      socket_socket_set_ip(tobj, g_value_get_string(value));
      break;
    case PROP_USER:
      socket_socket_set_user(tobj, g_value_get_string(value));
      break;
    case PROP_PWD:
      socket_socket_set_pwd(tobj, g_value_get_string(value));
      break;
    case PROP_CLIENT_ID:
      socket_socket_set_clientID(tobj, g_value_get_string(value));
      break;

    case PROP_DESCRIBE:
      socket_socket_set_describe(tobj, g_value_get_string(value));
      break;
    case PROP_NAME:
      socket_socket_set_name(tobj, g_value_get_string(value));
      break;
    case PROP_NAME_ALIAS:
      socket_socket_set_nameAlias(tobj, g_value_get_string(value));
      break;
    case PROP_CLASS:
      socket_socket_set_class(tobj, g_value_get_string(value));
      break;
//float
    case PROP_X:
      socket_socket_set_x(tobj, g_value_get_float(value));
      break;
    case PROP_Y:
      socket_socket_set_y(tobj, g_value_get_float(value));
      break;
    case PROP_Z:
      socket_socket_set_z(tobj, g_value_get_float(value));
      break;

    case PROP_BUFFER:
      tobj->buffer = g_value_get_pointer(value);
      break;
    case PROP_FUNC_SEND:
      tobj->funcSend = g_value_get_pointer(value);
      break;
    case PROP_CHANNEL:
      tobj->channel = g_value_get_pointer(value);
      break;
    case PROP_CONN:
      tobj->conn = g_value_get_pointer(value);
      break;
    case PROP_FUNC_PREFIX_SEND:
      tobj->funcPrefixSend = g_value_get_pointer(value);
      break;

    case PROP_DATA:
      tobj->data = g_value_get_pointer(value);
      break;
    case PROP_ADDR:
      tobj->addr = g_value_get_pointer(value);
      break;
    case PROP_SOCKET:
      tobj->socket = g_value_get_pointer(value);
      break;
    case PROP_CLIENT_ADDRESS:
      tobj->clientAddress = g_value_get_pointer(value);
      break;

    case PROP_NEXT:
      socket_socket_set_next(tobj, g_value_get_pointer(value));
      break;
    case PROP_SON:
      socket_socket_set_son(tobj, g_value_get_pointer(value));
      break;
    case PROP_PARENT:
      socket_socket_set_parent(tobj, g_value_get_pointer(value));
      break;
    case PROP_PRIVATE:
      socket_socket_set_private(tobj, g_value_get_pointer(value));
      break;

    default:
      g_assert_not_reached();
    }
}

static void
socket_socket_get_property(GObject *gobject,
                          guint prop_id,
                          GValue *value,
                          GParamSpec *pspec)
{
  SocketSocket *tobj = (SocketSocket *)gobject;

  g_assert_cmpint(prop_id, !=, 0);
  g_assert_cmpint(prop_id, !=, N_PROPERTIES);
  g_assert(pspec == properties[prop_id]);

  switch (prop_id)
    {
    case PROP_ID:
      g_value_set_int64(value, tobj->id);
      break;
    case PROP_PARENT_ID:
      g_value_set_int64(value, tobj->id);
      break;
    case PROP_TIMEOUT:
      g_value_set_int64(value, tobj->timeout);
      break;
    case PROP_INTERVAL:
      g_value_set_int64(value, tobj->interval);
      break;

    case PROP_FD:
      g_value_set_int(value, tobj->fd);
      break;
    case PROP_PORT:
      g_value_set_int(value, tobj->port);
      break;
    case PROP_TYPE:
      g_value_set_int(value, tobj->type);
      break;
    case PROP_DEFERRED_EXECUTION:
      g_value_set_int(value, tobj->deferredExecution);
      break;

    case PROP_BAUD:
      g_value_set_int(value, tobj->baud);
      break;
    case PROP_DATA_BIT:
      g_value_set_int(value, tobj->dataBit);
      break;
    case PROP_STOP_BIT:
      g_value_set_int(value, tobj->stopBit);
      break;
    case PROP_PARITY:
      g_value_set_int(value, tobj->parity);
      break;

    case PROP_STATUS:
      g_value_set_int(value, tobj->status);
      break;
    case PROP_ENABLE:
      g_value_set_int(value, tobj->enable);
      break;
    case PROP_UPDATE:
      g_value_set_int(value, tobj->update);
      break;
    case PROP_MUTEX:
      g_value_set_int(value, tobj->mutex);
      break;

    case PROP_BUFFER_SIZE:
      g_value_set_int(value, tobj->bufferSize);
      break;
    case PROP_NREAD:
      g_value_set_int(value, tobj->nread);
      break;
    case PROP_NWROTE:
      g_value_set_int(value, tobj->nwrote);
      break;

    case PROP_IP:
      g_value_set_string(value, tobj->ip);
      break;
    case PROP_USER:
      g_value_set_string(value, tobj->user);
      break;
    case PROP_PWD:
      g_value_set_string(value, tobj->pwd);
      break;
    case PROP_CLIENT_ID:
      g_value_set_string(value, tobj->clientID);
      break;

    case PROP_DESCRIBE:
      g_value_set_string(value, tobj->describe);
      break;
    case PROP_NAME:
      g_value_set_string(value, tobj->name);
      break;
    case PROP_NAME_ALIAS:
      g_value_set_string(value, tobj->nameAlias);
      break;
    case PROP_CLASS:
      g_value_set_string(value, tobj->class);
      break;

    case PROP_X:
      g_value_set_float(value, tobj->x);
      break;
    case PROP_Y:
      g_value_set_float(value, tobj->y);
      break;
    case PROP_Z:
      g_value_set_float(value, tobj->z);
      break;

    case PROP_BUFFER:
      g_value_set_pointer(value, tobj->buffer);
      break;
    case PROP_FUNC_SEND:
      g_value_set_pointer(value, tobj->funcSend);
      break;
    case PROP_CHANNEL:
      g_value_set_pointer(value, tobj->channel);
      break;
    case PROP_CONN:
      g_value_set_pointer(value, tobj->conn);
      break;
    case PROP_FUNC_PREFIX_SEND:
      g_value_set_pointer(value, tobj->funcPrefixSend);
      break;

    case PROP_DATA:
      g_value_set_pointer(value, tobj->data);
      break;
    case PROP_ADDR:
      g_value_set_pointer(value, tobj->addr);
      break;
    case PROP_SOCKET:
      g_value_set_pointer(value, tobj->socket);
      break;
    case PROP_CLIENT_ADDRESS:
      g_value_set_pointer(value, tobj->clientAddress);
      break;

    case PROP_NEXT:
      g_value_set_pointer(value, tobj->next);
      break;
    case PROP_SON:
      g_value_set_pointer(value, tobj->son);
      break;
    case PROP_PARENT:
      g_value_set_pointer(value, tobj->parent);
      break;
    case PROP_PRIVATE:
      g_value_set_pointer(value, tobj->private);
      break;
    default:
      g_assert_not_reached();
    }
}

static void
socket_socket_class_init(SocketSocketClass *klass)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS(klass);

  properties[PROP_ID] = g_param_spec_int64("id", "id", "Id",
      -1, G_MAXINT64, 0, G_PARAM_READWRITE);
  properties[PROP_PARENT_ID] = g_param_spec_int64(
      "parentID", "ParentId", "parent_Id",
      -1, G_MAXINT64, 0, G_PARAM_READWRITE);
  properties[PROP_TIMEOUT] = g_param_spec_int64(
      "timeout", "Timeout", "timeout",
      -1, G_MAXINT64, 0, G_PARAM_READWRITE);
  properties[PROP_INTERVAL] = g_param_spec_int64(
      "interval", "Interval", "interval",
      -1, G_MAXINT64, 0, G_PARAM_READWRITE);

  properties[PROP_STATUS] = g_param_spec_int("status", "Status", "Status",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_ENABLE] = g_param_spec_int("enable", "Enable", "enable",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_UPDATE] = g_param_spec_int("update", "Update", "update",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_MUTEX] = g_param_spec_int("mutex", "Mutex", "MUTEX",
      G_MININT, G_MAXINT, 0, G_PARAM_READWRITE);

  properties[PROP_FD] = g_param_spec_int("fd", "Fd", "fd",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_PORT] = g_param_spec_int("port", "Port", "port",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_TYPE] = g_param_spec_int("type", "Type", "type",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_DEFERRED_EXECUTION] = g_param_spec_int(
      "deferredExecution", "DeferredExecution", "DeferredExecution",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);

  properties[PROP_BAUD] = g_param_spec_int("baud", "Baud", "baud",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_DATA_BIT] = g_param_spec_int(
      "dataBit", "DataBit", "dataBit",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_STOP_BIT] = g_param_spec_int(
      "stopBit", "StopBit", "stopBit",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_PARITY] = g_param_spec_int("parity", "Parity", "parity",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);

  properties[PROP_BUFFER_SIZE] = g_param_spec_int(
      "bufferSize", "BufferSize", "buffer size",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_NREAD] = g_param_spec_int(
      "nread", "Nread", "read size",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_NWROTE] = g_param_spec_int(
      "nwrote", "Nwrote", "wrote size",
      -1, G_MAXINT, 0, G_PARAM_READWRITE);
  properties[PROP_IP] = g_param_spec_string("ip", "Ip", "Ip",
      NULL, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
      //NULL, G_PARAM_READWRITE);
  properties[PROP_USER] = g_param_spec_string("user", "user", "user",
      NULL, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_PWD] = g_param_spec_string("pwd", "pwd", "pwd",
      NULL, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_CLIENT_ID] = g_param_spec_string(
      "clientID", "ClientId", "clientID",
      NULL, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);

  properties[PROP_DESCRIBE] = g_param_spec_string(
      "describe", "describe", "describe",
      NULL, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_NAME] = g_param_spec_string(
      "name", "name", "name",
      NULL, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_NAME_ALIAS] = g_param_spec_string(
      "nameAlias", "nameAlias", "nameAlias",
      NULL, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_CLASS] = g_param_spec_string(
      "class", "Class", "CLASS",
      NULL, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);

  properties[PROP_X] = g_param_spec_float(
      "x", "X", "X",
      -G_MAXFLOAT, G_MAXFLOAT, 0, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_Y] = g_param_spec_float(
      "y", "Y", "Y",
      -G_MAXFLOAT, G_MAXFLOAT, 0, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_Z] = g_param_spec_float(
      "z", "Z", "Z",
      -G_MAXFLOAT, G_MAXFLOAT, 0, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);

  properties[PROP_BUFFER] = g_param_spec_pointer(
      "buffer", "Buffer", "buffer",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_FUNC_SEND] = g_param_spec_pointer(
      "funcSend", "FuncSend", "send function",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_CHANNEL] = g_param_spec_pointer(
      "channel", "Channel", "channel",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_CONN] = g_param_spec_pointer(
      "conn", "Conn", "conn",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_FUNC_PREFIX_SEND] = g_param_spec_pointer(
      "funcPrefixSend", "FuncPrefixSend", "send prefix function",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);

  properties[PROP_DATA] = g_param_spec_pointer("data", "Data", "data",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_ADDR] = g_param_spec_pointer("addr", "Addr", "addr",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_SOCKET] = g_param_spec_pointer(
      "socket", "Socket", "socket",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_CLIENT_ADDRESS] = g_param_spec_pointer(
      "clientAddress", "clientAddress", "client address",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);

  properties[PROP_SON] = g_param_spec_pointer("son", "son", "son",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_NEXT] = g_param_spec_pointer("next", "next", "next",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_PARENT] = g_param_spec_pointer("parent", "parent", "parent",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
  properties[PROP_PRIVATE] = g_param_spec_pointer(
      "private", "private", "private",
      G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);

  gobject_class->set_property = socket_socket_set_property;
  gobject_class->get_property = socket_socket_get_property;
  gobject_class->finalize = socket_socket_finalize;

  g_object_class_install_properties(gobject_class, N_PROPERTIES, properties);
}

static void
socket_socket_init(SocketSocket *self)
{
  self->enable = FALSE;
  self->update = FALSE;
  self->user = NULL;
  self->pwd = NULL;
  self->clientID = NULL;
}

SocketSocket *socket_socket_new(void)
{
  return g_object_new(SOCKET_SOCKET_TYPE, NULL);
}
void socket_driver__print_hex(const uint8_t *buffer, size_t size)
{
  gsize i;

  for(i = 0; i < size; i++) {
    g_print("%02x ", (unsigned char)buffer[i]);
  }
  g_print("\n");
}
